package com.kingyea.mobilepolice.apimanage.config;

import feign.codec.Encoder;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Mr.Lin
 * @version v1.0.0
 * @description
 * @date Created in 2017/11/21 9:04
 */
@Configuration
public class UploadConfig {

    //方案一
//    @Bean
//    public MapFormHttpMessageConverter mapFormHttpMessageConverter(MultipartFileHttpMessageConverter multipartFileHttpMessageConverter) {
//        MapFormHttpMessageConverter mapFormHttpMessageConverter = new MapFormHttpMessageConverter();
//        mapFormHttpMessageConverter.addPartConverter(multipartFileHttpMessageConverter);
//        return mapFormHttpMessageConverter;
//    }
//
//    @Bean
//    public MultipartFileHttpMessageConverter multipartFileHttpMessageConverter() {
//        return new MultipartFileHttpMessageConverter();
//    }

//    // 方案二
//    @Bean
//    public Encoder feignEncoder(ObjectFactory<HttpMessageConverters> messageConverters) {
//        return new FeignSpringFormEncoder(messageConverters);
//    }

    // 方案三
    @Bean
    public Encoder feignEncoder(ObjectFactory<HttpMessageConverters> messageConverters) {
//        System.out.println("1---------------------------------------------------------------------------------------");
        return new FeignSpringFormEncoder();
    }


//    @Bean
//    public Feign.Builder feignBuilder(){
//        System.out.println("2---------------------------------------------------------------------------------------");
//        return Feign.builder()
////                .decoder(new JacksonDecoder())
//                .encoder(new FeignSpringFormEncoder());
//    }
}